<?php
namespace Home\Model;
use Think\Model;
use Think\Db\Driver\Sqlsrv;
class CzjSszsxxModel extends Model {
	/**
	 * 添加新的税收数据
	 * @param [type] $type [description]1 地税 2国税
	 * @param [type] $data [description]
	 */
	public function addNewRow($type,$data)
	{
		$new_row=array(
			'zssj'=>$data['rkrq'],
			'zsxm'=>$data['zsxm'],
			'zsje'=>$data['se'],
			'zsdw'=>$type,
			'fromid'=>$data['id'],
			'drbatch'=>$data['group_key'],
			'addtime'=>date("Y-m-d H:i:s"),
		);
		if(empty($data['mssql_comid']))
		{
			//查询企业id
			$md_com=D("CzjCom");
			$com=$md_com->findBySbh($data['nsrsbh']);
			if(empty($com))
			{
				$com=$md_com->findByName($data['nsrmc']);
				if(empty($com))
				{
					addnewLog("id[".$data['id']."]数据写入mssql时.企业[".$data['nsrsbh']."][".$data['nsrmc']."]未找到;",'ss_add_'.$type);
					return false;
				}
			}
		}
		

		$new_row['zscom']=$data['mssql_comid'];
		$state=$this->data($new_row)->add();
		if($state==false) addnewLog("id[".$data['id']."]数据写入mssql时.数据库保存失败:[".$this->_sql()."];",'ss_add');
		return $state;
		//
	}
}